//
//  XMDaZiDateView.m
//  XunMi
//
//  Created by MacBook on 2024/3/6.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import "XMDaZiDateView.h"
#import "XMDaZiDateCollectionViewCell.h"

@interface XMDaZiDateView ()<UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *collectionView;

@end

@implementation XMDaZiDateView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = kHEXA(@"#F04B61", 16);
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.itemSize = CGSizeMake(kScreenWidth / 7, 70);
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        layout.minimumLineSpacing = 0;
        layout.minimumInteritemSpacing = 0;
        self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
        self.collectionView.delegate = self;
        self.collectionView.dataSource = self;
        [self.collectionView registerNib:kNibWithName(kStringFromClass(XMDaZiDateCollectionViewCell)) forCellWithReuseIdentifier:kStringFromClass(XMDaZiDateCollectionViewCell)];
        [self addSubview:_collectionView];
        [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];
    }
    return self;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 7;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    XMDaZiDateCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kStringFromClass(XMDaZiDateCollectionViewCell) forIndexPath:indexPath];
    return cell;
}

@end
